package com.example.a2209_mianshi.app

import android.app.Application
import com.example.a2209_mianshi.flow_eventbus.EventBusInitializer
import com.example.a2209_mianshi.widget.AppConfig
import com.tencent.mmkv.MMKV
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
class App : Application() {
    companion object {
        private lateinit var app: App
        fun getAppContext(): App {
            return app
        }
    }
    override fun onCreate() {
        super.onCreate()
        app = this
        EventBusInitializer.init(this)
        initMMKV()
    }
    /**
     * MMKV初始化
     */
    private fun initMMKV() {
        if (AppConfig.MMKV_ROOT_DIR_PATH.isEmpty()) {
            MMKV.initialize(this)
        } else {
            MMKV.initialize(this, AppConfig.MMKV_ROOT_DIR_PATH)
        }
    }
}